<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>电子表</title>
	<style>
		h1{
			font-size: 20px;
			color: skyblue;}
	</style>
	
	<script>
		window.onload=function(){
			setInterval(function(){
				var date=new Date();
		var t=date.getTime();
		console.log(t);
		var year=date.getFullYear();
		var month=date.getMonth()+1;
		var day=date.getDate();
		var week=date.getDay();
		var hours=date.getHours();
		var min=date.getMinutes();
		var sec=date.getSeconds();
		switch(week){
         case 0:
         week='天';
         break;
         case 1:
         week='一'
         break;
         case 2:
         week='二'
         break;
         case 3:
         week='三'
         break;
         case 4:
         week='四'
         break;
         case 5:
         week='五'
         break;
         case 6:
         week='六'
         break;
     
		}

		var str='当前时间为:'+year+'年'+month+'月'+day+'日，周'+week+' '+getone(hours)+'时'+ getTwo(min)+'分'+getTwo(sec)+'秒'
		
	  document.getElementById('txt').innerText=str;
		},1000);

	  function getone(num1){
	  	// return num1<12? '上午'+num1:'下午'+num1-12;//三元
	  if (num1>12) {
	  	return '下午'+ (num1-12);
	  }else if(num1<12){
	  	return '上午'+num1
	  }else{
	  	return '凌晨'+num1;
	  }

	  }

      function getTwo(num){
      return num<10? '0'+num:num+'';
    
      }
		}
		
	</script>
</head>
<body>
	<h1 id="txt"></h1>
</body>
</html>